package com.zxj.system.controller.user;


import com.zxj.common.core.controller.BaseController;
import com.zxj.common.core.domain.R;
import com.zxj.common.core.domain.vo.PageVO;
import com.zxj.system.domain.exam.dto.ExamQueryPageDTO;
import com.zxj.system.domain.exam.vo.ExamVO;
import com.zxj.system.domain.user.dto.UserDTO;
import com.zxj.system.domain.user.dto.UserQueryDTO;
import com.zxj.system.domain.user.vo.UserVO;
import com.zxj.system.service.user.IUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author zxj2022
 * @since 2025-01-01
 */
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
@Slf4j
@Tag(name = "用户管理相关接口", description = "用户管理相关接口")
public class UserController extends BaseController {
    private final IUserService userService;


    @GetMapping("/page/list")
    @Operation(summary = "获取C端用户信息列表", description = "分页获取C端用户信息列表")
    @ApiResponse(responseCode = "1000", description = "操作成功")
    @ApiResponse(responseCode = "2000", description = "服务繁忙请稍后重试")
    @ApiResponse(responseCode = "3102", description = "用户不存在")
    @ApiResponse(responseCode = "3103", description = "用户名或密码错误")
    public R<PageVO<UserVO>> pageQuery(UserQueryDTO userQueryDTO) {
        log.info("接收到分页获取用户信息请求, 请求参数：{}", userQueryDTO);
        return R.ok(userService.pageQuery(userQueryDTO));
    }


    @PutMapping("/updateStatus")
    //拉黑：限制用户操作   解禁：放开对于用户限制
    @Operation(summary = "更新数据库中用户的状态信息", description = "更新数据库中用户的状态信息")
    @ApiResponse(responseCode = "1000", description = "操作成功")
    @ApiResponse(responseCode = "2000", description = "服务繁忙请稍后重试")
    @ApiResponse(responseCode = "3102", description = "用户不存在")
    @ApiResponse(responseCode = "3103", description = "用户名或密码错误")
    public R<Void> updateStatus(@RequestBody UserDTO userDTO) {
        log.info("接收到更新用户状态请求, 请求参数：{}", userDTO);
        return toR(userService.updateStatus(userDTO));
    }
}
